<template>
  <view class="home">
    <!-- 介绍 -->
    <view class="index-intro">
      <view>{{ hello }}</view>
      <!-- <view style="font-size: 35rpx">成都大学
        <span class="custom-icon-xiangxia custom-icon " style="font-size: 30rpx"></span>
      </view> -->
      <view style="font-size: 25rpx">所有快递统统包吃，请放心交给我....</view>
    </view>
    <!-- 轮播图 -->
    <u-swiper
      :list="list"
      height="600"
      mode="none"
      img-mode="aspectFill"
      :class="['indexSwiper']"
      border-bottom-radius="100"
    ></u-swiper>

    <view class="make-order">
      <view @click="toTakeBox">
        <view class="custom-icon custom-icon-kuaidibaoguo index-icon-1"></view>
        <view style="font-weight: 800">快递下单</view>
      </view>

      <view @click="toMoveHouse">
        <view class="custom-icon custom-icon-waimai index-icon-2"></view>
        <view style="font-weight: 800">搬家下单</view>
      </view>
    </view>

    <choose-school ref="home"></choose-school>
  </view>
</template>

<script>
import ChooseSchool from "./components/chooseSchool";
import { formatData, messageDingyue } from "@/common/js/utils";

export default {
  components: {
    ChooseSchool,
  },
  data() {
    return {
      hello: "您好，游客",
      list: [
        {
          // image: require("@/static/index/indexBanner.jpg"),
          image: "https://s1.ax1x.com/2020/09/20/woXWU1.jpg",
          title: "昨夜星辰昨夜风，画楼西畔桂堂东",
        },
        {
          image: "https://s1.ax1x.com/2020/09/20/woXWU1.jpg",
          title: "身无彩凤双飞翼，心有灵犀一点通",
        },
        // {
        //   image: "https://s1.ax1x.com/2020/09/20/woXOUI.jpg",
        //   title: "谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳",
        // },
      ],

    };
  },
  mounted() {

  },
  onLoad(option) {},
  onShow() {
    // 判断是否登录
    if (this.vuex_userInfo.isLogin) {
      this.hello = "您好  " + this.vuex_userInfo.nickName;
      console.log(true);
    } else {
      console.log(false);
      this.hello = "您好，游客";
    }
  },
  methods: {
    //   跳转到 代取快递
    toTakeBox() {
      // 这里获取 大学名称list
      // this.$u.api.getSchoolListApi().then((res) => {
      //   console.log(res);
      //   this.$refs.home.list = res.data;
      //   // 打开弹窗
      //   this.$refs.home.show = true;
      // });

      // 第一次进入获取数据  第二次进入就从vuex获取
      if (this.vuex_AddressData.length > 0) {
        this.$refs.home.list = this.vuex_AddressData;
        console.log(this.vuex_AddressData);
        // 打开弹窗
        this.$refs.home.show = true;
      } else {
        //登录就将三级联动数据存到vuex
        this.$u.api.getLinkageInfoApi().then((res) => {
          // 数据格式化处理
          var formatD = formatData(res.data);
          this.$u.vuex("vuex_AddressData", formatD);
          this.$refs.home.list = this.vuex_AddressData;
          // 打开弹窗
          this.$refs.home.show = true;
        });
      }
    },
    // 跳转到 搬家
    toMoveHouse() {
      this.$u.route({
        url: "/pages/moveHouse/moveHouse",
      });
    },
  },
};
</script>

<style lang="less" scoped>
.home {
  background-color: #eff5f7;
  height: 100vh;
  .index-intro {
    position: absolute;
    top: 90rpx;
    z-index: 2;
    color: #ffffff;
    left: 30rpx;
  }
  .index-swiper {
    z-index: 1;
  }
  .make-order {
    background-color: #ffffff;
    height: 220rpx;
    // line-height: 250rpx;
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: center;
    margin: 0 20px;
    position: relative;
    border-radius: 10px;
    top: -40px;
    & > view:nth-child(1) {
      border-right: 2rpx solid #f6f6f6;
    }
    & > view {
      flex: 1;
      font-weight: 600;
      .index-icon-1 {
        font-size: 40px;
        color: #d0de4c;
        margin-bottom: 10px;
      }
      .index-icon-2 {
        font-size: 30px;
        color: #d0de4c;
        margin-bottom: 13px;
      }
    }
  }
}
</style>
